/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package org.teacup.eightdays.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import org.teacup.eightdays.model.*;
import org.teacup.eightdays.dao.*;
import org.teacup.eightdays.service.*;
import org.teacup.eightdays.vo.query.*;

/**
 * @author Abner email:521yexu2008(a)163.com
 * @version 1.0
 * @since 1.0
 */

@Entity
@Table(name = "delivery_address")
public class DeliveryAddress extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "DeliveryAddress";
	public static final String ALIAS_DELIVERY_ADDRESS_ID = "ID";
	public static final String ALIAS_SCHOOL_ID = "所在学校";
	public static final String ALIAS_MEMBERINFO_ID = "所属会员";
	public static final String ALIAS_NAME = "收件人姓名";
	public static final String ALIAS_MOBILE_NO = "手机号码";
	public static final String ALIAS_ADDRESS = "详细地址";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * ID       db_column: delivery_address_id 
     */ 	
	
	private java.lang.Long deliveryAddressId;
    /**
     * 所在学校       db_column: school_id 
     */ 	
	
	private java.lang.Long schoolId;
    /**
     * 所属会员       db_column: memberinfo_id 
     */ 	
	
	private java.lang.Long memberinfoId;
    /**
     * 收件人姓名       db_column: name 
     */ 	
	@Length(max=50)
	private java.lang.String name;
    /**
     * 手机号码       db_column: mobile_no 
     */ 	
	@Length(max=15)
	private java.lang.String mobileNo;
    /**
     * 详细地址       db_column: address 
     */ 	
	@Length(max=500)
	private java.lang.String address;
	//columns END


	public DeliveryAddress(){
	}

	public DeliveryAddress(
		java.lang.Long deliveryAddressId
	){
		this.deliveryAddressId = deliveryAddressId;
	}

	

	public void setDeliveryAddressId(java.lang.Long value) {
		this.deliveryAddressId = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "delivery_address_id", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getDeliveryAddressId() {
		return this.deliveryAddressId;
	}
	
	@Column(name = "school_id", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getSchoolId() {
		return this.schoolId;
	}
	
	public void setSchoolId(java.lang.Long value) {
		this.schoolId = value;
	}
	
	@Column(name = "memberinfo_id", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getMemberinfoId() {
		return this.memberinfoId;
	}
	
	public void setMemberinfoId(java.lang.Long value) {
		this.memberinfoId = value;
	}
	
	@Column(name = "name", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
	public java.lang.String getName() {
		return this.name;
	}
	
	public void setName(java.lang.String value) {
		this.name = value;
	}
	
	@Column(name = "mobile_no", unique = false, nullable = true, insertable = true, updatable = true, length = 15)
	public java.lang.String getMobileNo() {
		return this.mobileNo;
	}
	
	public void setMobileNo(java.lang.String value) {
		this.mobileNo = value;
	}
	
	@Column(name = "address", unique = false, nullable = true, insertable = true, updatable = true, length = 500)
	public java.lang.String getAddress() {
		return this.address;
	}
	
	public void setAddress(java.lang.String value) {
		this.address = value;
	}
	
	
	private School school;
	public void setSchool(School school){
		this.school = school;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "school_id",nullable = false, insertable = false, updatable = false) 
	})
	public School getSchool() {
		return school;
	}
	
	private Memberinfo memberinfo;
	public void setMemberinfo(Memberinfo memberinfo){
		this.memberinfo = memberinfo;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "memberinfo_id",nullable = false, insertable = false, updatable = false) 
	})
	public Memberinfo getMemberinfo() {
		return memberinfo;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("DeliveryAddressId",getDeliveryAddressId())
			.append("SchoolId",getSchoolId())
			.append("MemberinfoId",getMemberinfoId())
			.append("Name",getName())
			.append("MobileNo",getMobileNo())
			.append("Address",getAddress())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getDeliveryAddressId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof DeliveryAddress == false) return false;
		if(this == obj) return true;
		DeliveryAddress other = (DeliveryAddress)obj;
		return new EqualsBuilder()
			.append(getDeliveryAddressId(),other.getDeliveryAddressId())
			.isEquals();
	}
}

